package com.ruoyi.project.search.viewDdjFaultStatistics.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.project.search.viewDdjFaultStatistics.domain.ViewDdjFaultStatistics;
import com.ruoyi.project.search.viewDdjFaultStatistics.service.IViewDdjFaultStatisticsService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 堆垛机问题统计Controller
 * 
 * @author ruoyi
 * @date 2024-04-23
 */
@Controller
@RequestMapping("/search/viewDdjFaultStatistics")
public class ViewDdjFaultStatisticsController extends BaseController
{
    private String prefix = "search";

    @Autowired
    private IViewDdjFaultStatisticsService viewDdjFaultStatisticsService;

    @GetMapping()
    public String viewDdjFaultStatistics()
    {
        return prefix + "/viewDdjFaultStatistics";
    }

    /**
     * 查询堆垛机问题统计列表
     */
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(ViewDdjFaultStatistics viewDdjFaultStatistics)
    {
        startPage();
        List<ViewDdjFaultStatistics> list = viewDdjFaultStatisticsService.selectViewDdjFaultStatisticsList(viewDdjFaultStatistics);
        return getDataTable(list);
    }

    /**
     * 导出堆垛机问题统计列表
     */
    @Log(title = "堆垛机问题统计", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(ViewDdjFaultStatistics viewDdjFaultStatistics)
    {
        List<ViewDdjFaultStatistics> list = viewDdjFaultStatisticsService.selectViewDdjFaultStatisticsList(viewDdjFaultStatistics);
        ExcelUtil<ViewDdjFaultStatistics> util = new ExcelUtil<ViewDdjFaultStatistics>(ViewDdjFaultStatistics.class);
        return util.exportExcel(list, "堆垛机问题统计数据");
    }

    /**
     * 新增堆垛机问题统计
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存堆垛机问题统计
     */
    @Log(title = "堆垛机问题统计", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(ViewDdjFaultStatistics viewDdjFaultStatistics)
    {
        return toAjax(viewDdjFaultStatisticsService.insertViewDdjFaultStatistics(viewDdjFaultStatistics));
    }

    /**
     * 修改堆垛机问题统计
     */
    @GetMapping("/edit/{warehouseId}")
    public String edit(@PathVariable("warehouseId") String warehouseId, ModelMap mmap)
    {
        ViewDdjFaultStatistics viewDdjFaultStatistics = viewDdjFaultStatisticsService.selectViewDdjFaultStatisticsByWarehouseId(warehouseId);
        mmap.put("viewDdjFaultStatistics", viewDdjFaultStatistics);
        return prefix + "/edit";
    }

    /**
     * 修改保存堆垛机问题统计
     */
    @Log(title = "堆垛机问题统计", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(ViewDdjFaultStatistics viewDdjFaultStatistics)
    {
        return toAjax(viewDdjFaultStatisticsService.updateViewDdjFaultStatistics(viewDdjFaultStatistics));
    }

    /**
     * 删除堆垛机问题统计
     */
    @Log(title = "堆垛机问题统计", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(viewDdjFaultStatisticsService.deleteViewDdjFaultStatisticsByWarehouseIds(ids));
    }
}
